home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / Devices / SlotVInstall / slotVInstall.p < prev    next >
Encoding:
Text File  |  1992-07-15  |  2.0 KB  |  95 lines  |  [TEXT/MPS ]

  1. { requires SIOW }
  2.  
  3. {
  4. This little program installs a slot VBL task for the 
  5. main screen, even if the main screen uses built-in
  6. video, by getting the gdRefNum and calling GetDctlEntry
  7. to find the slot number.
  8.  
  9. The VBL will run 5 times and then be dequeued.
  10.  
  11. Requires the MPW SIOW standard I/O package.
  12.  
  13. Grobbins 9/91
  14. }
  15.  
  16. PROGRAM slotVInstallTest;
  17.  
  18. USES OSUtils, Retrace, PasLibIntf, Devices;
  19.  
  20. CONST kVBLCount = 60;
  21.  
  22. TYPE
  23.     enhVBLTask = RECORD
  24.         theVBLTask: VBLTask;
  25.         theGlobal: ^LongInt;
  26.     END;
  27.     enhVBLTaskPtr = ^enhVBLTask;
  28.  
  29. VAR
  30.     retCode: OSErr;
  31.     response: LONGINT;
  32.     
  33.     myVBLTask: enhVBLTask;
  34.     vblGlobalLongInt, tempLongInt: LONGINT;
  35.     
  36.     GDevHand: GDHandle;
  37.     mainGDRefNum: INTEGER;
  38.     DCEHand: AuxDCEHandle;
  39.     
  40.     FUNCTION getVBLRec: enhVBLTaskPtr;
  41.     INLINE $2E88; { put A0 on stack }
  42.  
  43.     PROCEDURE myVBLProc;
  44.     VAR
  45.         theEnhVBLTaskRecPtr: enhVBLTaskPtr;
  46.     BEGIN
  47.         theEnhVBLTaskRecPtr := getVBLRec;
  48.         
  49.         theEnhVBLTaskRecPtr^.theGlobal^ :=
  50.             theEnhVBLTaskRecPtr^.theGlobal^ + 1;
  51.         { reset VBL }
  52.         theEnhVBLTaskRecPtr^.theVBLTask.vblCount := kVBLCount;
  53.     END;
  54.     
  55. BEGIN
  56.     GDevHand := GetMainDevice;
  57.     IF GDevHand = NIL THEN BEGIN WriteLn('no main device!'); HALT; END;
  58.     
  59.     mainGDRefNum := GDevHand^^.gdRefNum;
  60.     
  61.     DCEHand := AuxDCEHandle(GetDctlEntry(mainGDRefNum));
  62.     WriteLn('main slot is ',DCEHand^^.dCtlSlot);
  63.  
  64.     
  65.     WriteLn( 'installing vbl...');
  66.     PLFlush(output);
  67.     
  68.     { set up VBL task }
  69.     myVBLTask.theVBLTask.qType := ORD(vType);
  70.     myVBLTask.theVBLTask.vblAddr := @myVBLProc;
  71.     myVBLTask.theVBLTask.vblCount := kVBLCount;
  72.     myVBLTask.theVBLTask.vblPhase := 0;
  73.     myVBLTask.theGlobal := @vblGlobalLongInt;
  74.     
  75.     vblGlobalLongInt := 0;
  76.     tempLongInt := 0;
  77.  
  78.     retCode := SlotVInstall(@myVBLTask, DCEHand^^.dCtlSlot);
  79.     IF retCode <> noErr THEN WriteLn( 'VInstall failed')
  80.     ELSE BEGIN
  81.         WriteLn('Installed.');
  82.         PLFlush(output);
  83.         REPEAT
  84.             IF vblGlobalLongInt <> tempLongInt THEN
  85.             BEGIN
  86.                 WriteLn ('vblGlobal = ',vblGlobalLongInt);
  87.                 PLFlush(output);
  88.                 tempLongInt := vblGlobalLongInt;
  89.             END; { IF }
  90.         UNTIL vblGlobalLongInt >= 5;
  91.         
  92.         retCode := SlotVRemove(@myVBLTask, DCEHand^^.dCtlSlot);
  93.     END; { ELSE }
  94.     
  95. END.